<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/7/6
 * Time: 9:59
 */

namespace App\Models;


use Doctrine\DBAL\Driver\Mysqli\Driver;
use Illuminate\Database\Eloquent\Model;

class DriverOthers extends Model
{
    use Common;
    protected $table = 'driver_others';
    protected $casts = [
        'identity_photo' => 'array',
        'licence_photo' => 'array'
    ];
    // 加上对应的字段
    protected $fillable = ['driver_id','company_id','city','auditor_id','identity_photo','licence_photo','province'];
    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 司机
     */
    public function driver()
    {
        return $this->hasOne(Drivers::class ,'id','driver_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 公司
     */
    public function companys()
    {
        return $this->hasOne(Company::class ,'id','company_id');
    }
    /**
     * 所属公司
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @Author 姿势就是力量
     */
    public function company()
    {
        return $this->belongsTo(Company::class, 'company_id', 'id');
    }
    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 城市
     */
    public function citys()
    {
        return $this->hasOne(Region::class ,'id','city');
    }
    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 城市
     */
    public function city()
    {
        return $this->hasOne(Region::class ,'id','city');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * 审核信息
     */
    public function auditor()
    {
        return $this->belongsTo(Management::class, 'auditor_id', 'id');
    }
    /**
     * 评论
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     * @Author 姿势就是力量
     */
    public function comment()
    {
        return $this->hasMany(Comment::class, 'driver_id', 'id');
    }
}